public class Test {

    public static void drawMap(Shape shape){

        shape.draw();
    }

    public static void main(String[] args) {
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Flower flower = new Flower();


        Shape[] shapes={rect,cycle,flower};//向上转型
        for(Shape shape:shapes){
            shape.draw();
        }

        for(int i=0;i<shapes.length;i++){
            Shape shape=shapes[i];
            shape.draw();
        }
    }





    public static void main2(String[] args) {
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Flower flower = new Flower();

String [] shapes={"cycle","rect","cycle","rect","flower"};
for(String shape:shapes){
    if(shape.equals("cycle")){//equals:表示相等的意思
        cycle.draw();
    }else if(shape.equals("rect")){
        rect.draw();
    }else if(shape.equals("flower")){
        flower.draw();
    }
}


    }



    public static void main1(String[] args){
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Flower flower = new Flower();

        drawMap(rect);

        drawMap(cycle);
        drawMap(flower);

    }
}
